package com.study.springcloud.controller;

import cn.hutool.core.util.IdUtil;
import com.study.springcloud.entities.CommonResult;
import com.study.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @GetMapping("payment/hystrix/ok/{id}")
    public String PaymentInfo_OK(Integer id){
        return paymentService.PaymentInfo_OK(id);
    }

    @GetMapping("payment/hystrix/timeout/{id}")
    public String PaymentInfo_TimeOut(Integer id){
        return paymentService.PaymentInfo_TimeOut(id);
    }

    //****熔断*****
    @GetMapping("payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id")Long id){

        String result = paymentService.paymentCircuitBreaker(id);
        log.info("***result=="+result);
        return result;
    }
}
